from sqlalchemy import Column, Integer, String, Text, DateTime, ForeignKey
from sqlalchemy.orm import relationship
from models.base import Base

class Schedule(Base):
    __tablename__ = "schedules"
    __table_args__ = {
        'comment': '用户日程表'  # 添加表注释
    }

    id = Column(Integer, primary_key=True, comment='主键ID', autoincrement=True)
    user_id = Column(Integer, ForeignKey("users.id"), nullable=False, index=True, comment='关联用户ID')
    title = Column(String(100), nullable=False, comment='日程标题')
    start_time = Column(DateTime, nullable=False, comment='开始时间')
    end_time = Column(DateTime, nullable=True, comment='结束时间')
    reminder_at = Column(DateTime, nullable=True, comment='提醒时间')
    notes = Column(Text, nullable=True, comment='备注内容')

    user = relationship("User", back_populates="schedules")